package com.lv.service.utils

import android.content.Context
import android.view.View
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.callback.NavigationCallback
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.GsonUtils
import com.luck.picture.lib.entity.LocalMedia
import com.lv.common.bean.CustomMessageChatBean
import com.lv.common.utils.ARoutUtils
import com.lv.common.utils.Constants
import com.lv.service.bean.ViewTypeStringBean

/**
 * 作者： ygx
 * 创建日期：2023/2/11 2:49 PM
 * 签名： 天行健，君子以自强不息；地势坤，君子以厚德载物。
 * -    _              _           _     _   ____  _             _ _
 * -   / \   _ __   __| |_ __ ___ (_) __| | / ___|| |_ _   _  __| (_) ___
 * -  / _ \ | '_ \ / _` | '__/ _ \| |/ _` | \___ \| __| | | |/ _` | |/ _ \
 * - / ___ \| | | | (_| | | | (_) | | (_| |  ___) | |_| |_| | (_| | | (_) |
 * -/_/   \_\_| |_|\__,_|_|  \___/|_|\__,_| |____/ \__|\__,_|\__,_|_|\___/
 * <p>
 * You never know what you can do until you try !
 * ----------------------------------------------------------------
 * 描述：
 */
class YgxAroutPageKt {

    companion object {
        //先进首页再进目标路由
        fun aroutPager_home(mContext: Context, t: String, ti: String, tt: String) {
            ARouter.getInstance().build(ARoutUtils.HomeActivityURL)
                .withInt("tabId", 2)
                .navigation(
                    mContext,
                    object : NavigationCallback {
                        override fun onFound(postcard: Postcard?) {
                        }

                        override fun onLost(postcard: Postcard?) {
                        }

                        override fun onArrival(postcard: Postcard?) {
                            when (t) {


                                Constants.MESSAGE_TAG_1046, Constants.MESSAGE_TAG_121 -> {//列表1046 详情121

                                }


                                else -> {

                                }

                            }
                        }

                        override fun onInterrupt(postcard: Postcard?) {
                        }

                    })
        }

        fun aroutPager(
            mContext: Context,
            jt: CustomMessageChatBean,
            mViewChatBg: View?
        ) {
            mViewChatBg?.setOnClickListener {
                val t = jt.t
                val ti = jt.ti
                val tt = jt.tt
                when (t) {
                    Constants.MESSAGE_TAG_1000 -> {//1000 货圈风险下线


                    }


                    else -> {

                    }

                }

            }


        }

        fun scanMediaPic(banner: String?, position: Int = 0) {
            if (banner.isNullOrEmpty()) {
                return
            }
            val mFacoryDatas = mutableListOf<ViewTypeStringBean>()
            mFacoryDatas.add(ViewTypeStringBean(banner, ViewTypeStringBean.PIC_TYPE))
            val json = GsonUtils.toJson(mFacoryDatas)
            ARouter.getInstance().build(ARoutUtils.ShowMediaDetailsActivity)
                .withInt("position", position)
                .withString("data", json)
                .navigation()
        }

        fun scanMediaVideo(banner: String?, position: Int = 0) {
            if (banner.isNullOrEmpty()) {
                return
            }
            val mFacoryDatas = mutableListOf<ViewTypeStringBean>()
            mFacoryDatas.add(ViewTypeStringBean(banner, ViewTypeStringBean.VEDIO_TYPE))
            val json = GsonUtils.toJson(mFacoryDatas)
            ARouter.getInstance().build(ARoutUtils.ShowMediaDetailsActivity)
                .withInt("position", position)
                .withString("data", json)
                .navigation()
        }

        fun scanMediaPic(banner: MutableList<String>, position: Int = 0) {
            if (banner.size == 0) {
                return
            }
            val mFacoryDatas = mutableListOf<ViewTypeStringBean>()
            for (i in 0 until banner.size) {
                val tvivItemBean = banner[i]
                mFacoryDatas.add(ViewTypeStringBean(tvivItemBean, ViewTypeStringBean.PIC_TYPE))
            }
            val json = GsonUtils.toJson(mFacoryDatas)
            ARouter.getInstance().build(ARoutUtils.ShowMediaDetailsActivity)
                .withInt("position", position)
                .withString("data", json)
                .navigation()
        }

        fun scanMediaPicLocal(banner: MutableList<LocalMedia?>, position: Int = 0) {
            if (banner.size == 0) {
                return
            }
            val mFacoryDatas = mutableListOf<ViewTypeStringBean>()
            for (i in 0 until banner.size) {
                val tvivItemBean = banner[i]?.compressPath ?: banner[i]?.realPath ?: ""
                mFacoryDatas.add(ViewTypeStringBean(tvivItemBean, ViewTypeStringBean.PIC_TYPE))
            }
            val json = GsonUtils.toJson(mFacoryDatas)
            ARouter.getInstance().build(ARoutUtils.ShowMediaDetailsActivity)
                .withInt("position", position)
                .withString("data", json)
                .navigation()
        }

        fun scanMediaPicType(mFacoryDatas: MutableList<ViewTypeStringBean>, position: Int = 0) {
            if (mFacoryDatas.size == 0) {
                return
            }
            val json = GsonUtils.toJson(mFacoryDatas)
            ARouter.getInstance().build(ARoutUtils.ShowMediaDetailsActivity)
                .withInt("position", position)
                .withString("data", json)
                .navigation()
        }
    }
}